// var i;
// var $uI_UnlockNewEquip_UIBindings = require("./UI_UnlockNewEquip_UIBindings");
// var $uIView = require("./UIView");
// var $bundleConfig = require("./BundleConfig");
// var $audioManager = require("./AudioManager");
// var $excel = require("./Excel");
// var p = cc._decorator;
// var h = p.ccclass;
// var f = p.property;
// var g = p.inspector;
// var _ = (function (e) {
//     function t() {
//         var t = (null !== e && e.apply(this, arguments)) || this;
//         t.auto_ui = null;
//         return t;
//     }
//     __extends(t, e);
//     t.prototype._show = function (e) {
//         this.shuiGuoIds = e.shuiGuoIds;
//         this.clickCallBack = e.callBack;
//         this.ShowOne(this.shuiGuoIds.shift());
//         this.auto_ui.node_guang.stopAllActions();
//         this.auto_ui.node_guang.runAction(cc.repeatForever(cc.rotateBy(5, 360)));
//     };
//     t.prototype.ShowOne = function (e) {
//         var t = this;
//         $audioManager.AudioMgr.playEffect("effect/getReward");
//         this.auto_ui.node_view.scale = 0;
//         this.auto_ui.node_view.runAction(cc.scaleTo(0.5, 1, 1));
//         this._loadRes($bundleConfig.BundleNames.Common, "res/player/player" + (e - 1e3) + "_1", cc.SpriteFrame).then(
//             function (e) {
//                 t.auto_ui.sp_iconSprite.spriteFrame = e;
//             }
//         );
//         var o = $excel.Excel.shuiguo(e);
//         this.auto_ui.txt_nameLabel.string = "" + o.name;
//     };
//     t.prototype._clickListener = function (e) {
//         switch (e) {
//             case this.auto_ui.btn_mengban:
//                 if (this.shuiGuoIds.length > 0) {
//                     this.ShowOne(this.shuiGuoIds.shift());
//                 } else {
//                     this.clickCallBack && this.clickCallBack();
//                     this._close();
//                 }
//         }
//     };
//     __decorate([f($uI_UnlockNewEquip_UIBindings.default)], t.prototype, "auto_ui", void 0);
//     return __decorate([h], t);
// })($uIView.default);
// exports.default = _;


// import UI_UnlockNewEquip_UIBindings from "./UI_UnlockNewEquip_UIBindings";
// import UIView from "./UIView";
// import {BundleNames} from "./BundleConfig";
// import {AudioMgr} from "./AudioManager";
// import {Excel} from "./Excel";

// const { ccclass, property, inspector } = cc._decorator;

// /**
//  * 建议类名：UnlockNewEquipUI
//  */
// @ccclass
// class UI_UnlockNewEquip extends UIView {
//     @property(UI_UnlockNewEquip_UIBindings)
//     auto_ui: UI_UnlockNewEquip_UIBindings = null;

//     private shuiGuoIds: number[] = [];
//     private clickCallBack: Function | null = null;

//     /**
//      * 显示新解锁装备的UI
//      * @param {Object} data 包含水果IDs和回调函数的对象
//      * 建议方法名：showUnlockNewEquipUI
//      */
//     protected _show(data: { shuiGuoIds: number[], callBack: Function }) {
//         this.shuiGuoIds = data.shuiGuoIds;
//         this.clickCallBack = data.callBack;
//         this.ShowOne(this.shuiGuoIds.shift());
//         this.auto_ui.node_guang.stopAllActions();
//         this.auto_ui.node_guang.runAction(cc.repeatForever(cc.rotateBy(5, 360)));
//     }

//     /**
//      * 显示单个水果装备
//      * @param {number} id 水果ID
//      * 建议方法名：showSingleEquip
//      */
//     private ShowOne(id: number) {
//         const self = this;
//         AudioMgr.playEffect("effect/getReward");
//         this.auto_ui.node_view.scale = 0;
//         this.auto_ui.node_view.runAction(cc.scaleTo(0.5, 1, 1));
//         this._loadRes(BundleNames.Common, "res/player/player" + (id - 1000) + "_1", cc.SpriteFrame)
//             .then((spriteFrame: cc.SpriteFrame) => {
//                 self.auto_ui.sp_iconSprite.spriteFrame = spriteFrame;
//             });
//         const fruitData = Excel.shuiguo(id);
//         this.auto_ui.txt_nameLabel.string = fruitData.name;
//     }

//     /**
//      * 按钮点击事件监听器
//      * @param {cc.Node} targetNode 点击的按钮节点
//      * 建议方法名：onButtonClick
//      */
//     protected _clickListener(targetNode: cc.Button) {
//         switch (targetNode) {
//             case this.auto_ui.btn_mengban:
//                 if (this.shuiGuoIds.length > 0) {
//                     this.ShowOne(this.shuiGuoIds.shift());
//                 } else {
//                     this.clickCallBack && this.clickCallBack();
//                     this._close();
//                 }
//                 break;
//         }
//     }
// }

// export default UI_UnlockNewEquip;

import UI_UnlockNewEquip_UIBindings from "./UI_UnlockNewEquip_UIBindings";
import UIViewBase from "./UIView";
import { BundleNames } from "./BundleConfig";
import { AudioMgr } from "./AudioManager";
import { Excel } from "./Excel";

const { ccclass, property, inspector } = cc._decorator;

/**
 * 建议类名：UnlockNewEquipUI
 */
@ccclass
class ViewUnlockNewEquip extends UIViewBase {
    @property(UI_UnlockNewEquip_UIBindings)
    auto_ui: UI_UnlockNewEquip_UIBindings = null;

    private fruitIds: number[] = [];
    private clickCallback: Function | null = null;

    /**
     * 显示新解锁装备的UI
     * @param {Object} data 包含水果IDs和回调函数的对象
     * 建议方法名：showUnlockNewEquipUI
     */
    protected _show(data: { shuiGuoIds: number[], callBack: Function }) {
        this.fruitIds = data.shuiGuoIds;
        this.clickCallback = data.callBack;
        this.showSingleEquip(this.fruitIds.shift());
        this.auto_ui.node_guang.stopAllActions();
        this.auto_ui.node_guang.runAction(cc.repeatForever(cc.rotateBy(5, 360)));
    }

    /**
     * 显示单个水果装备
     * @param {number} id 水果ID
     * 建议方法名：showSingleEquip
     */
    private showSingleEquip(id: number) {
        const self = this;
        AudioMgr.playSoundEffect("effect/getReward");
        this.auto_ui.node_view.scale = 0;
        this.auto_ui.node_view.runAction(cc.scaleTo(0.5, 1, 1));
        this._loadRes(BundleNames.Common, "res/player/player" + (id - 1000) + "_1", cc.SpriteFrame)
            .then((spriteFrame: cc.SpriteFrame) => {
                self.auto_ui.sp_iconSprite.spriteFrame = spriteFrame;
            });
        const fruitData = Excel.shuiguo(id);
        this.auto_ui.txt_nameLabel.string = fruitData.name;
    }

    /**
     * 按钮点击事件监听器
     * @param {cc.Button} targetNode 点击的按钮节点
     * 建议方法名：onButtonClick
     */
    protected _clickListener(targetNode: cc.Button) {
        if (targetNode === this.auto_ui.btn_mengban) {
            if (this.fruitIds.length > 0) {
                this.showSingleEquip(this.fruitIds.shift());
            } else {
                this.clickCallback && this.clickCallback();
                this._close();
            }
        }
    }
}

export default ViewUnlockNewEquip;